#!/bin/bash
MODULES="library templates/glutproject test/unittest test/bouncing tools/videocapture tools/dumpinput tools/wheelchair"
TESTMODULES="test/unittest"

for MODULE in $MODULES; do
    CURRENTPATH=`pwd`
    cd $MODULE
    echo "Building module "$MODULE"... "$*
    make $* > /dev/null
    cd $CURRENTPATH
done

for MODULE in $TESTMODULES; do
    CURRENTPATH=`pwd`
    cd $MODULE
    echo "Running test module "$MODULE"... "
    ./run.sh

    if [ $? != "0" ]; then
        echo "Error found"
        exit $?
    fi

    cd $CURRENTPATH
done
